package com.kk.model;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import java.util.Set;

@EqualsAndHashCode(callSuper = true)
@Data
@Entity
public class Permission extends BaseEntity {

    private String name;
    private String permission;
    //多对多在两边都需要设置为立刻加载模式，一对多则只需要在一的这边设置为立刻加载模式
//    @ManyToMany(mappedBy = "permissions", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
//    private Set<Role> roles;//角色权限关系   多对多        //去掉此处，因为会Caused by: java.lang.StackOverflowError: null错误，如果需要根据permisson获取所有的角色的话，就是用中间表来实现吧，暂时先这样

    public Permission() {
    }

    public Permission(String name) {
        this.name = name;
    }
}
